upgrade to typescript 2.0 and fix broken build process#47
upgrade to typescript 2.0 and fix broken build process#47FredKSchott merged 9 commits intomasterfrom
Conversation
|
yay! taking a look |
test/service-worker_test.js
Outdated
| serviceWorker.generateServiceWorker(); | ||
| }, Error.AssertionError, '`project` & `buildRoot` options are required'); | ||
| return serviceWorker.generateServiceWorker() | ||
| .then(() => { throw new Error('generateServiceWorker() resolved, expected rejection!'); }) |
There was a problem hiding this comment.
I would do Promise inversions as two callback to then(), so that you don't have to worry about the exception you throw in then() flowing into catch(). Then just assert.fail() in the first callback. Alternatively, we have a handy invert() function hangout out around here somewhere...
There was a problem hiding this comment.
There was a problem hiding this comment.
nice, I like this.
tsconfig.json
Outdated
| "src/**/*.ts", | ||
| "typings/index.d.ts" | ||
| ], | ||
| "files": [ |
There was a problem hiding this comment.
TS 2.x supports includes and excludes. Use those instead of files.
There was a problem hiding this comment.
🎉 nice! It's behavior is a little weird, which is why I hadn't been able to get it working before. Files still need to be referenced in the files array. ¯_(ツ)_/¯
There was a problem hiding this comment.
you shouldn't. We don't use files at all in the analyzer
There was a problem hiding this comment.
Please try to remove files before submitting. One file is replaced by compilerOptions.lib, the other should go in includes.
There was a problem hiding this comment.
👍 got it! Taking out"typings/index.d.ts" was what caused the error I was seeing, but it turns out it was a problem with typings and not typescript.
| @@ -8,7 +8,6 @@ | |||
| "merge-stream": "registry:dt/merge-stream#1.0.0+20160313224417", | |||
There was a problem hiding this comment.
can you migrate to @types while we're at this?
There was a problem hiding this comment.
not all of them are supported yet, but I'll migrate the ones I can
There was a problem hiding this comment.
which ones? All of these come from DT, so they should be available in @types
There was a problem hiding this comment.
Only DT stuff in their 2.0 branch is in @types. They're using this as a chance to standardize on modern practices.
|
TRAVIS Y U NO LIKE? Anything we can do to fix that here too so we have green travis checks? wrt https://travis-ci.org/Polymer/polymer-build/jobs/161702741 (unless node 4 is no longer unsupported) |
f347fa5 to
f5cada9
Compare
fe68851 to
18020ae
Compare
|
@usergenic the |
|
@justinfagnani PTAL |
tsconfig.json
Outdated
| } | ||
| "include": [ | ||
| "custom_typings/**/*.ts", | ||
| "node_modules/@types/**/*.ts", |
There was a problem hiding this comment.
I don't think you need or want this line. tsc automatically looks for these when you use node resolution
| "rewriteTsconfig": true | ||
| } | ||
| "include": [ | ||
| "custom_typings/**/*.ts", |
There was a problem hiding this comment.
@rictic do you remember why we use /// <reference path="../custom_typings/main.d.ts" /> in analyzer.ts rather than include custom_typings in tsconfig? Is it for declarations and dependers?
There was a problem hiding this comment.
Yeah, it's for the generated .d.ts declarations file. If you only mention the dependency in your tsconfig then downstream users won't see the custom typings.
There was a problem hiding this comment.
I'll add this for the sw-precache custom typing and we can look into publishing it directly to npm. All the others are internal only and shouldn't affect the polymer-build declarations
gulpfile.js
Outdated
|
|
||
| gulp.task('depcheck', () => | ||
| depcheck(__dirname, {}) | ||
| depcheck(__dirname, {ignoreMatches: ['@types/**']}) |
There was a problem hiding this comment.
can you comment the ignore?
There was a problem hiding this comment.
We should really make that part of the default ignoreMatches
There was a problem hiding this comment.
+10, I'll create a PR and comment for now
There was a problem hiding this comment.
Already tracking here: depcheck/depcheck#163
test/service-worker_test.js
Outdated
| }, Error.AssertionError, '`project` & `buildRoot` options are required'); | ||
| return serviceWorker.generateServiceWorker() | ||
| .then( | ||
| () => { throw new Error('generateServiceWorker() resolved, expected rejection!'); }, |
There was a problem hiding this comment.
instead of throwing, you can: assert.fail('generateServiceWorker() resolved, expected rejection!')
There was a problem hiding this comment.
Any reason to prefer assert.fail over new Error?
There was a problem hiding this comment.
The UX. I think an uncaught error is reported different, and tries to display a stacktrace. Here we know it's a plain failure and the stack won't help.
There was a problem hiding this comment.
I'm fine with either, the difference seems minor
|
@justinfagnani @rictic PTAL |
e792601 to
75a531f
Compare
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
| async _buildBundles(): Promise<Map<string, string>> { | ||
| let bundles = await this._getBundles(); |
There was a problem hiding this comment.
Here and elsewhere: preferred style is const by default, let only when necessary.
There was a problem hiding this comment.
Agreed, but I'd like to keep the scope of this PR small for now. I'll make a separate PR to address this across the repo once this has been merged.
There was a problem hiding this comment.
Agreed w/ the agree. In the future, just do the async/await in another PR also :)
| ? urlFromPath(this.root, this.shell) | ||
| : this.sharedBundleUrl; | ||
| let sharedDeps = bundles.get(sharedDepsBundle) || []; | ||
| let promises: Promise<any>[] = []; |
There was a problem hiding this comment.
Minimize use of any, it's usually a code smell. Would this work?
const promises: Promise<{url: string, contents: string}>[] = []There was a problem hiding this comment.
Agreed, but I'd like to keep the scope of this PR small for now. This diff was only a indentation change due to a move over to async-await above. I'll make a separate PR to address this.
| "declaration": true, | ||
| "noImplicitAny": true, | ||
| "removeComments": false, | ||
| "noLib": true, |
There was a problem hiding this comment.
noLib still makes sense, or
"lib": ["es2017"],
| @@ -8,7 +8,6 @@ | |||
| "merge-stream": "registry:dt/merge-stream#1.0.0+20160313224417", | |||
There was a problem hiding this comment.
Only DT stuff in their 2.0 branch is in @types. They're using this as a chance to standardize on modern practices.
|
As a code review style note, when possible instead of rewriting existing commits add --fixup commits instead, and you can rebase them right before going to master. It makes it easier for us to see only the new changes. |
|
@rictic TIL! I've never used the @rictic @justinfagnani thanks for the help so far with all the different TypeScript config options, feeling much more confident in our config setup now. |
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
| async _buildBundles(): Promise<Map<string, string>> { | ||
| let bundles = await this._getBundles(); |
There was a problem hiding this comment.
Agreed w/ the agree. In the future, just do the async/await in another PR also :)
@usergenic and I ran into problems with
gulp-typescriptyesterday, this upgrades to the latest 2.0 version and fixes some issues with config, custom_typings, etc./cc @usergenic @justinfagnani